package com.example.whac_a_mole;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Activity_find extends AppCompatActivity {
    private EditText edit_user;
    private EditText edit_oldpswd;
    private EditText edit_newpswd;
    private Button button_find;
    private Button button_rturn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_find);
        setTitle("打地鼠-修改密码");
        edit_user=findViewById(R.id.edit_find_1);
        edit_oldpswd=findViewById(R.id.edit_find_old);
        edit_newpswd=findViewById(R.id.edit_find_new);
        button_find=findViewById(R.id.button_find1);
        button_rturn=findViewById(R.id.button_find2);
        button_find.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String user=edit_user.getText().toString().trim();
                String passwd1=edit_oldpswd.getText().toString().trim();
                String passwd2=edit_newpswd.getText().toString().trim();
                if(user.equals("")||passwd1.equals("")||passwd2.equals(""))
                {
                    Toast.makeText(Activity_find.this,"账号或者密码不能为空,请检查后重试!",Toast.LENGTH_LONG).show();
                }
                else
                {
                    new DataBase(Activity_find.this).setpasswd(user,passwd1,passwd2);
                    Toast.makeText(Activity_find.this,"密码修改成功!",Toast.LENGTH_LONG).show();
                }

            }

        });
        button_rturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(Activity_find.this,Activity_login.class));
            }
        });


    }
}
